<?php
/**
 * Created by Veyron
 * User: Vy
 * motto:现在的拼搏 为了更好的明天
 * Class: Http
 * day:  2020/1/15
 * Time: 23:23
 */

namespace app\admin\exception;


use think\exception\Handle;
use think\exception\HttpException;
use think\exception\HttpResponseException;
use think\Request;
use think\Response;
use Throwable;

class Http extends Handle
{
    public $httpStatus = 500;
    /**
     * Render an exception into an HTTP response.
     *
     * @access public
     * @param Request   $request
     * @param Throwable $e
     * @return Response
     */
    public function render($request, Throwable $e): Response
    {
        if($e->getCode()){
            $httpStatus = $e->getCode();
        }else{
            $httpStatus = $this->httpStatus;
        }

        return show(config('status.error'),$e->getMessage(),[],$httpStatus);
    }
}
